package com.dp.client.views;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ErrorEvent;
import com.google.gwt.event.dom.client.ErrorHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Button;

public class Prueba extends Composite {
	private HorizontalPanel horizontalPanel_1;
	private VerticalPanel verticalPanel;
	private HorizontalPanel horizontalPanel;
	private Label lblLabelFf;
	private Button btnClick;

	public Prueba() {
		
		verticalPanel = new VerticalPanel();
		initWidget(verticalPanel);
		
		horizontalPanel = new HorizontalPanel();
		verticalPanel.add(horizontalPanel);
		horizontalPanel.setWidth("430px");
		
		lblLabelFf = new Label("Label ff");
		horizontalPanel.add(lblLabelFf);
		
		btnClick = new Button("Click");
		horizontalPanel.add(btnClick);
		
		horizontalPanel_1 = new HorizontalPanel();
		horizontalPanel_1.setSize("100%", "100%");
		verticalPanel.add(horizontalPanel_1);
		cargar();
	}

	private void cargar() {
		 final Image image = new Image();
		 image.addErrorHandler(new ErrorHandler() {
		      public void onError(ErrorEvent event) {
		        lblLabelFf.setText("An error occurred while loading.");
		      }
		    });
		 String url="http://maps.googleapis.com/maps/api/staticmap?center=";
		 String center="63.259591,-144.667969";
		 url+=center;
		 url+="&zoom=6&size=400x400";
		 String marker1="&markers=color:blue%7Clabel:S%7C63.259591,-144.6679698";
		 url+=marker1;
		 String marker2="&markers=color:blue%7Clabel:S%7C62.259591,-144.6679698";
		 url+=marker2;
		 String path="&path=color:0x00FFFF|weight:5|63.259591,-144.6679698|62.259591,-144.6679698";
		 url+=path;
		 url+="&sensor=false";
		 
		 image.setUrl(url);
		 btnClick.addClickHandler(new ClickHandler() {
		      public void onClick(ClickEvent event) {
		        image.setVisible(true);
		      }
		    });
		 image.setVisible(false);
		    btnClick.setWidth("120px");
		 horizontalPanel_1.add(image);
	}
	

}
